<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use App\Http\Model\User;
use App\Http\Model\Gift;
use App\Http\Model\GiftBag;

class RepairBagGiftBatch extends Command
{
    protected $signature = 'RepairBagGiftBatch';

    protected $description = '背包礼物批量赠送撤销';

    private $giftModel;
    private $giftBagModel;

    public function __construct()
    {
        parent::__construct();

        $this->giftModel = new Gift();
        $this->giftBagModel = new GiftBag();
    }

    public function handle()
    {
        $batchId = 3053;
        
        do {
            $this->handleDo($batchId);

        } while (false);


        return true;
    }

    public function handleDo($batchId)
    {
        $batchId = 3053;
        
        do {
            //锁
            $key = 'giftbagbatchHandle:'.$batchId;
            $ifLock = redis_lock($key, 3600);
            if (!$ifLock){
                // echo "锁\r\n";
                // break;
            }
            $info = $this->giftModel->getGiftSendBatch($batchId);


            print_r($info);


        } while (false);


        return true;
    }

}